package com.tensquare.notice.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tensquare.notice.dao.NoticeFreshDao;
import com.tensquare.notice.pojo.NoticeFresh;
import com.tensquare.notice.service.NoticeFreshService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author BAO
 * @version V1.0
 * @Package tensquare.notice.service.impl
 * @date 2020/12/4 22:01
 * @description:
 */
@Service
public class NoticeFreshServiceImpl implements NoticeFreshService {

    @Autowired
    private NoticeFreshDao noticeFreshDao;
    @Override
    public Page<NoticeFresh> freshPage(String id, Integer current, Integer size) {

        NoticeFresh noticeFresh = new NoticeFresh();
        noticeFresh.setUserId(id);
        Page<NoticeFresh> page = new Page<>(current, size);
        List<NoticeFresh> list = noticeFreshDao.selectPage(page, new EntityWrapper<NoticeFresh>(noticeFresh));
        page.setRecords(list);

        return page;
    }

    @Override
    public int freshDelete(NoticeFresh noticeFresh) {

        Integer delete = noticeFreshDao.delete(new EntityWrapper<NoticeFresh>(noticeFresh));
        return delete;
    }
}
